home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / chkmodem.zip / CHKMODEM.BAS next >
BASIC Source File  |  1990-06-21  |  15KB  |  485 lines

  1. '******************************************************************************
  2. '
  3. '       File:   CHKMODEM.BAS
  4. '
  5. '       Date:   06/21/90
  6. '
  7. '         By:   Gary G. Hendershot
  8. '               Soft Sale Limited BBS
  9. '               (703) 569-6876
  10. '
  11. '    Purpose:   Utility program to find HAYES command compatible
  12. '               modems on COM1 thru COM4.  Report maximum possible
  13. '               baud rate for all modems found.  Test a selected
  14. '               modem for DTR and CD line settings.
  15. '
  16. '               This utility is part of an installation program
  17. '               under development which when finished will
  18. '               automate the installation of a commercial
  19. '               vertical market micro to mainframe dialup
  20. '               communications program.
  21. '
  22. '               The intent is to make the installation of the
  23. '               program as idiot proof as possible. In this program
  24. '               segment no configuration file is created.  Responses
  25. '               are sent to the screen only.
  26. '
  27. '       Note:   Both the EXECUTABLE and SOURCE files are included.
  28. '               The program conpiles under MS-BASIC Ver. 7.0 and
  29. '               MS-QuickBASIC 4.5.
  30. '
  31. '               The program makes CALLs to a Serial I/O Library called
  32. '               QBSERIAL Ver. 1.5.  This Library was written by
  33. '               Jeff Sumberg and was obtained from the SailBoard BBS
  34. '               at (201) 831-8152
  35. '
  36. '               I do not intend to provide any support or upgrades to
  37. '               this program.  It is offered AS IS to anyone interested
  38. '               in communications programming as an example of what
  39. '               compiled BASIC can do with a little help.
  40. '
  41. '               I would of course appreciate any comments or mods others
  42. '               might offer that would enhance the capabilities of this
  43. '               program to deliver the results described above.  Please
  44. '               leave any comments or mods addressed to the SYSOP at
  45. '               (703) 569-6876 or in writting to
  46. '                       Gary G. Hendershot
  47. '                       7218 Reservoir Road
  48. '                       Springfield, VA  22150
  49. '
  50. '******************************************************************************
  51. '
  52. '       These DECLAREs are required by QBSERIAL.LIB
  53. '
  54. DECLARE SUB OpenComm CDECL ALIAS "_open_comm" (BYVAL Port%, BYVAL Wlen%, BYVAL Parity%, BYVAL Baud&, BYVAL HS%)
  55. DECLARE SUB CloseComm CDECL ALIAS "_close_comm" ()
  56. DECLARE FUNCTION WriteChar% CDECL (BYVAL Ascii%)
  57. DECLARE FUNCTION ReadChar% CDECL ()
  58. DECLARE SUB Transmit CDECL ALIAS "_transmit_string" (addr$)
  59. DECLARE FUNCTION DataWaiting% CDECL ALIAS "_data_waiting" ()
  60. DECLARE SUB ClearInputBuffer CDECL ALIAS "_clear_input_buffer" ()
  61. DECLARE SUB CarrierDetect CDECL ALIAS "_carrier_detect_flag" (BYVAL OnOff%)
  62. DECLARE SUB CDtrap CDECL ALIAS "_trap_mode" (BYVAL OnOff%)
  63. DECLARE FUNCTION CarrierLost% CDECL ALIAS "_carrier_state" ()
  64. DECLARE SUB DTRcontrol CDECL ALIAS "_dtr" (BYVAL OnOff%)
  65. '
  66. '$STATIC
  67. '
  68. DIM Report%(4,4)
  69. DIM FoundPort%(4)
  70. DIM Init%(4,60)
  71. DIM ModemPort%(4)
  72. DIM Respond$(30)
  73. '
  74. DEFINT A-Z
  75. '
  76. CONST   True = -1
  77. CONST   False = 0
  78. '
  79. Verbal:
  80.         Respond$(0)  = "OK"
  81.         Respond$(1)  = "CONNECT"
  82.         Respond$(2)  = "RING"
  83.         Respond$(3)  = "NO CARRIER"
  84.         Respond$(4)  = "ERROR"
  85.         Respond$(5)  = "CONNECT 1200"
  86.         Respond$(6)  = "NO DIALTONE"
  87.         Respond$(7)  = "BUSY"
  88.         Respond$(8)  = "NO ANSWER"
  89.         Respond$(9)  = "RESERVED"
  90.         Respond$(10) = "CONNECT 2400"
  91. '
  92. Numeric:
  93.         Respond$(20) = "0"
  94.         Respond$(21) = "1"
  95.         Respond$(22) = "2"
  96.         Respond$(23) = "3"
  97.         Respond$(24) = "4"
  98.         Respond$(25) = "5"
  99.         Respond$(26) = "6"
  100.         Respond$(27) = "7"
  101.         Respond$(28) = "8"
  102.         Respond$(29) = "9"
  103.         Respond$(30) = "10"
  104. '
  105. Main:
  106.         CLS
  107. '
  108.         Length = 8
  109.         Parity = 0
  110.         HS = 0
  111.         Send$ = "AT" + CHR$(13)
  112.         NextPort% = 0
  113.         PrevPort% = 0
  114.         ModemAvail% = 0
  115.  '
  116.         GOSUB TestPort1
  117.         GOSUB TestPort2
  118.         GOSUB TestPort3
  119.         GOSUB TestPort4
  120.         GOSUB PortReport
  121.         GOSUB HowManyModems
  122.         GOSUB ChooseActivePort
  123.         GOSUB CheckCDLine
  124.         GOSUB CheckDTRLine
  125.         DTRControl 0
  126.         CloseComm
  127. '
  128.         END
  129. '
  130. TestPort1:
  131.         Port = 1
  132.         Rate& = 0
  133.         GOSUB TickleIt
  134.         RETURN
  135. '
  136. TestPort2:
  137.         Port = 2
  138.         Rate& = 0
  139.         GOSUB TickleIt
  140.         RETURN
  141. '
  142. TestPort3:
  143.         Port = 3
  144.         Rate& = 0
  145.         GOSUB TickleIt
  146.         RETURN
  147. '
  148. TestPort4:
  149.         Port = 4
  150.         Rate& = 0
  151.         GOSUB TickleIt
  152.         RETURN
  153. '
  154. PortReport:
  155.         CLS
  156.         LOCATE 4, 15, 0
  157.         PRINT "An Ok marks a useable PORT/MODEM at a given BAUD"
  158.         LOCATE 8, 15
  159.         PRINT "300 BAUD"
  160.         LOCATE 8, 30
  161.         PRINT "1200 BAUD"
  162.         LOCATE 8, 45
  163.         PRINT "2400 BAUD"
  164.         LOCATE 8, 60
  165.         PRINT "9600 BAUD"
  166.         LOCATE 11, 5
  167.         PRINT "COM1:"
  168.         LOCATE 13, 5
  169.         PRINT "COM2:"
  170.         LOCATE 15, 5
  171.         PRINT "COM3:"
  172.         LOCATE 17, 5
  173.         PRINT "COM4:"
  174.         FOR X% = 1 TO 4
  175.                 FOR Y% = 1 TO 4
  176.                         LOCATE (X% * 2) + 9, (Y% * 15) + 3
  177.                         IF Y% = 1 THEN
  178.                                 Speed% = 300
  179.                         ELSEIF Y% = 2 THEN
  180.                                 Speed% = 1200
  181.                         ELSEIF Y% = 3 THEN
  182.                                 Speed% = 2400
  183.                         ELSEIF Y% = 4 THEN
  184.                                 Speed% =9600
  185.                         END IF
  186.                         IF Report%(X%,Y%) THEN
  187.                                 PRINT "Ok";
  188.                                 FoundPort%(X%) = Speed%
  189.                         END IF
  190.                 NEXT Y%
  191.         NEXT X%
  192.         LOCATE 20, 30
  193.         PRINT "Press Any Key to Continue"
  194.         A$=""
  195.         WHILE A$=""
  196.                 A$=INKEY$
  197.         WEND
  198.         RETURN
  199. '
  200. HowManyModems:
  201.         ModemAvail%=0
  202.         FOR X% = 1 TO 4
  203.                 IF FoundPort%(X%) THEN
  204.                         ModemAvail% = ModemAvail% + 1
  205.                         ModemPort%(ModemAvail%) = X%
  206.                 END IF
  207.         NEXT X%
  208.         RETURN
  209. '
  210. ChooseActivePort:
  211.         CLS
  212.         PRINT
  213.         PRINT
  214.         PRINT
  215.         IF ModemAvail% = 0 THEN
  216.                 PRINT
  217.                 PRINT "No MODEM found that responds to HAYES AT commands"
  218.                 PRINT
  219.                 PRINT
  220.                 PRINT "Press any key to exit program"
  221.                 PRINT
  222.                 A$ = ""
  223.                 WHILE A$ = ""
  224.                         A$ = INKEY$
  225.                 WEND
  226.                 RETURN
  227.         ELSEIF ModemAvail% > 0 THEN
  228.                 FOR X% = 1 TO ModemAvail%
  229.                         PRINT
  230.                         PRINT "There is a MODEM on COM";
  231.                         PRINT STR$(ModemPort%(X%));":";
  232.                         PRINT " responding properly at ";
  233.                         PRINT STR$(FoundPort%(ModemPort%(X%)));" Baud"
  234.                         PRINT
  235.                 NEXT X%
  236.                 GOSUB ChooseModem
  237.                 IF ChosenModem% = 0 THEN SYSTEM
  238.         END IF
  239.         OpenComm Port, Length, Parity, Rate&, HS
  240.         CarrierDetect 0
  241.         SOUND 32767,15:SOUND 32767,1
  242.         DTRcontrol 1
  243.         SOUND 32767,15:SOUND 32767,1
  244.         RETURN
  245. '
  246. CheckCDLine:
  247.         CLS
  248.         PRINT
  249.         PRINT
  250.         PRINT "Testing Carrier Detect"
  251.         PRINT
  252.         CarrierDetect 0
  253.         SOUND 32767,15:SOUND 32767,1
  254.         DTRControl 1
  255.  
  256.         SOUND 32767,15:SOUND 32767,1
  257.         Send$ = "ATQ0E0V1X1" + CHR$(13)
  258.         SOUND 32767,15:SOUND 32767,1
  259.         Transmit Send$
  260.         SOUND 32767,15:SOUND 32767,1
  261.         GOSUB GetResponse
  262.  
  263.         IF Response% = 5 THEN
  264.                 CD% = 0
  265.                 RETURN
  266.         END IF
  267.  
  268.         SOUND 32767,15:SOUND 32767,1
  269.         Send$